<%-- 
    Document   : listcurrency
    Created on : Nov 10, 2011, 12:43:04 AM
    Author     : Venus
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">


<%@page import="java.util.*, Beans.ThamSoHT, Beans.TienTe, Models.ThamSoHT_Model"%>
<!--
Danh sách các tham số hệ thống ở trang này :
order      areainfo     areamsg     status      arealang
newarea    areaname     save        action      arealist
enable     disable      search
-->
<script type="text/javascript">
    function keypress(e){
        //Hàm dùng để ngăn người dùng nhập các ký tự khác ký tự số vào TextBox
        var keypressed = null;
        if (window.event)
        {
            keypressed = window.event.keyCode; //IE
        }
        else
        {
            keypressed = e.which; //NON-IE, Standard
        }
        if (keypressed < 48 || keypressed > 57 )
        { //CharCode của 0 là 48 (Theo bảng mã ASCII)
            //CharCode của 9 là 57 (Theo bảng mã ASCII)
            if (keypressed == 8 || keypressed == 127  )
            {//Phím Delete và Phím Back
                return;
            }
            return false;
        }
    }
</script>
<%
            int langid = (Integer) session.getAttribute("langid"); // ngôn ngữ hiện tại
            String dsts = " 'all', 'chkcurrencymsg', 'currencyexist', 'currencylist', 'currencyname', 'delete', 'disable', 'enable', 'notice', 'order', 'rightmsg', 'status', 'symbols' ";
            ThamSoHT[] mdsts = ThamSoHT_Model.DSThamSo(dsts, langid); // mảng chứa các tham số của trang này.

            String all = mdsts[0].getTenTS();
            String chkcurrencymsg = mdsts[1].getTenTS();
            String currencyexist = mdsts[2].getTenTS();
            String currencylist = mdsts[3].getTenTS();
            String currencyname = mdsts[4].getTenTS();
            String delete = mdsts[5].getTenTS();
            String disable = mdsts[6].getTenTS();
            String enable = mdsts[7].getTenTS();
            String notice = mdsts[8].getTenTS();
            String order = mdsts[9].getTenTS();
            String rightmsg = mdsts[10].getTenTS();
            String status = mdsts[11].getTenTS();
            String symbols = mdsts[12].getTenTS();

            String msgright = notice + "/" + rightmsg;
            String msgchkcurrency = notice + "/" + chkcurrencymsg;
            String msg = notice + "/" + currencyexist;
            Vector v = (Vector) request.getAttribute("DSTT");

            int numpage = 0;// khởi tạo số trang = 0
            int vsize = v.size();
            if (vsize % 4 == 0) // mỗi trang có 6 dòng
            {
                numpage = vsize / 4;
            } else {
                numpage = vsize / 4 + 1;
            }
            String xx = (String) request.getAttribute("item"); // trang hiện tại đang xem
            int item = Integer.parseInt(xx);
            int total = 0;

%>
<div class="title">
    <%=currencylist%>
    
</div>
<div class="content">
    <form name="dstiente" action="">
        <table class="mytable" border="0" cellpadding="0" cellspacing="0">
            <thead>
                <tr>
                    <th style="width: 9%;  ">                        
                        <input type="checkbox" onclick="CheckAllTT()">                        
                    </th>
                    <th style="width: 10%;  "><%=order%></th>
                    <th style="width: 34%; ">
                        <a href="#" id="titledskv1" style="margin-top: 5px;" class="down" lang="<%=msgright%>"  name="1" onclick="SortTenTT(this.className, this.name, this.lang)">
                            <div style="float:left"><%=currencyname%></div>
                            <div id="sortkv1" style=" margin-right: 28px;" class="down1"></div>
                        </a>
                    </th>
                    <th style="width: 20%; ">
                        <a href="#" id="titledskv2" style="margin-top: 5px;" class="down" lang="<%=msgright%>"  name="1" onclick="SortKyHieuTT(this.className, this.name, this.lang)">
                            <div style="float:left"><%=symbols%></div>
                            <div id="sortkv2" style=" margin-right: 25px;" class="down1"></div>
                        </a>
                    </th>
                    <th style=" ">
                        <a href="#" id="titledskv3" style="margin-top: 5px;" class="down" lang="<%=msgright%>"  name="1" onclick="SortTTTT(this.className, this.name, this.lang)">
                            <div><%=status%></div>
                            <div >
                                <div id="sortkv3" class="down2"></div>
                            </div>
                        </a>
                    </th>
                </tr>
                <tr id="searchTienTe">
                    <th><img style=" margin-top: 2px; margin-left: 3px; margin-bottom: -7px; cursor: pointer;"  alt="1" src="../images/search1.png" lang="<%=msgright%>" onclick="SearchTT(this.alt, this.lang)"></th>
                    <th></th>
                    <th><input type="textbox" style=" width: 140px;" name="TENTT" class="tentt text" ></th>
                    <th><input type="textbox" style=" width: 75px;" name="KYHIEU" class="kyhieu text" ></th>
                    <th>
                        <div>
                            <select  class="select" id="1" name="TINHTRANG" lang="<%=msgright%>" onchange="SearchTT(this.id, this.lang)">
                                <option value="all"><%=all%></option>
                                <option value="1"><%=enable%></option>
                                <option value="0"><%=disable%></option>
                            </select>
                        </div>
                    </th>
                </tr>
            </thead>
            <tbody>
                <%
                            for (int i = (item - 1) * 4; i < (item - 1) * 4 + 4 && i < vsize; i++) {
                                Beans.TienTe tt = (Beans.TienTe) v.elementAt(i);
                                total = total + 1;
                %>
                <tr>                    
                    <td class="STT"><input type="checkbox" value="<%= tt.getMaTTe()%>" class="optionTT" name="optionTT"></td>
                    <td class="STT"><%= i + 1%></td>
                    <td><a href="#" name="<%=tt.getMaTTe()%>" lang="<%=msgright%>" onclick="ShowLangTT(this.name, this.lang)"><%= tt.getTenTTe()%></a></td>
                    <td><%=tt.getKyHieu()%></td>
                    <td>
                        <select class="<%= tt.getMaTTe()%>" name="<%=msgchkcurrency%>" lang="<%=msgright%>" onchange="UpdateStatusTT(this.value, this.className, this.name, this.lang)">
                            <%
                                                            if (tt.getMacDinh() == 1) {%>
                            <option value="1"><%= enable%></option>
                            <option value="0"><%= disable%></option>
                            <%  } else {%>
                            <option value="0"><%= disable%></option>
                            <option value="1"><%= enable%></option>
                            <%  }
                            %>
                        </select>
                    </td>
                </tr>
                <%  }%>
            <input type="hidden" name="total" value="<%=total%>">
            </tbody>
        </table>
        <div style="float:left;">            
            <input type="button" style="margin-left: 0; margin-top: 5px; margin-bottom: 5px;" class="button" value ="<%=delete%>" id="1" lang="<%=msgright%>"  onclick="DeleteTT( this.id, this.lang)">            
        </div>
        <div class="pagination" style=" margin-bottom: 5px;">
            <%
                        int trang = 1;
                        if (item > 1) {
                            trang = item - 1;
                        }
            %>
            <%
                            if (vsize > 4) {%>
            <a href="#" class="prev"  name="<%= trang%>" lang="<%=msgright%>" onclick="Currency( this.name, this.lang)">«</a>
            <%
                                    for (int c = 1; c <= numpage; c++) {
                                        if (c != item) {
            %>              <a href="#"  name="<%= c%>" lang="<%=msgright%>" onclick="Currency( this.name, this.lang)" ><%= c%></a>
            <%          } else {%><a class="current"> <%= c%></a> <% }
                                    }
            %>
            <%      if (item + 1 <= numpage) {
                                        trang = item + 1;
                                    } else {
                                        trang = item;
                                    }
            %>
            <a href="#" class="next"  name="<%= trang%>" lang="<%=msgright%>" onclick="Currency( this.name, this.lang)">»</a>
            <%  }
            %>
        </div>
    </form>
</div>